home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Admin / ad_help.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  7.0 KB  |  273 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Help Control functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 2nd April 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25.  
  26.  
  27. $idx = new ad_settings();
  28.  
  29.  
  30. class ad_settings {
  31.  
  32.     var $base_url;
  33.  
  34.     function ad_settings() {
  35.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  36.  
  37.         switch($IN['code'])
  38.         {
  39.             case 'edit':
  40.                 $this->show_form('edit');
  41.                 break;
  42.             case 'new':
  43.                 $this->show_form('new');
  44.                 break;
  45.             
  46.             case 'doedit':
  47.                 $this->doedit();
  48.                 break;
  49.                 
  50.             case 'donew':
  51.                 $this->doadd();
  52.                 break;
  53.                 
  54.             case 'remove':
  55.                 $this->remove();
  56.                 break;
  57.             
  58.             //-------------------------
  59.             default:
  60.                 $this->list_files();
  61.                 break;
  62.         }
  63.         
  64.     }
  65.     
  66.     //-------------------------------------------------------------
  67.     // HELP FILE FUNCTIONS
  68.     //-------------------------------------------------------------
  69.     
  70.     function doedit()
  71.     {
  72.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
  73.         
  74.         if ($IN['id'] == "")
  75.         {
  76.             $ADMIN->error("You must pass a valid emoticon id, silly!");
  77.         }
  78.         
  79.         $text  = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['text'] ) );
  80.         $title = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['title'] ) );
  81.         $desc  = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['description'] ) );
  82.         
  83.         $db_string = $DB->compile_db_update_string( array( 'title'       => $title,
  84.                                                            'text'        => $text,
  85.                                                            'description' => $desc,
  86.                                                   )      );
  87.                                                   
  88.         $DB->query("UPDATE ibf_faq SET $db_string WHERE id='".$IN['id']."'");
  89.         
  90.         $std->boink_it($SKIN->base_url."&act=help");
  91.         exit();
  92.             
  93.         
  94.     }
  95.     
  96.     //=====================================================
  97.     
  98.     
  99.     function show_form($type='new')
  100.     {
  101.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  102.     
  103.         $ADMIN->page_detail = "You may add/edit and remove help files below.";
  104.         $ADMIN->page_title  = "Help File Management";
  105.         
  106.         //+-------------------------------
  107.         
  108.         if ($type != 'new')
  109.         {
  110.         
  111.             if ($IN['id'] == "")
  112.             {
  113.                 $ADMIN->error("You must pass a valid help file id, silly!");
  114.             }
  115.         
  116.             //+-------------------------------
  117.         
  118.             $DB->query("SELECT * FROM ibf_faq WHERE id='".$IN['id']."'");
  119.         
  120.             if ( ! $r = $DB->fetch_row() )
  121.             {
  122.                 $ADMIN->error("We could not find that help file in the database");
  123.             }
  124.         
  125.             //+-------------------------------
  126.             
  127.             $button = 'Edit this Help File';
  128.             $code   = 'doedit';
  129.         }
  130.         else
  131.         {
  132.             $r = array();
  133.             $button = 'Add this Help File';
  134.             $code   = 'donew';
  135.         }
  136.         
  137.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , $code ),
  138.                                                   2 => array( 'act'   , 'help'     ),
  139.                                                   3 => array( 'id'    , $IN['id'] ),
  140.                                          )      );
  141.         
  142.         
  143.         
  144.         $SKIN->td_header[] = array( " "  , "20%" );
  145.         $SKIN->td_header[] = array( " "  , "80%" );
  146.         
  147.         $r['text'] = preg_replace( "/<br>/i", "\n", stripslashes($r['text']) );
  148.          
  149.          //+-------------------------------
  150.         
  151.         $ADMIN->html .= $SKIN->start_table( $button );
  152.         
  153.         
  154.         $ADMIN->html .= $SKIN->add_td_row( array( "Help File Title",
  155.                                                   $SKIN->form_input('title'  , stripslashes($r['title']) ),
  156.                                          )      );
  157.                                          
  158.         $ADMIN->html .= $SKIN->add_td_row( array( "Help File Description",
  159.                                                   $SKIN->form_textarea('description', stripslashes($r['description']) ),
  160.                                          )      );
  161.                                          
  162.         $ADMIN->html .= $SKIN->add_td_row( array( "Help File Text",
  163.                                                   $SKIN->form_textarea('text', $r['text'], "60", "10" ),
  164.                                          )      );
  165.                                          
  166.         $ADMIN->html .= $SKIN->end_form($button);
  167.                                          
  168.         $ADMIN->html .= $SKIN->end_table();
  169.         
  170.         $ADMIN->output();
  171.     
  172.     }
  173.     
  174.     //=====================================================
  175.     
  176.     function remove()
  177.     {
  178.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  179.         
  180.         if ($IN['id'] == "")
  181.         {
  182.             $ADMIN->error("You must pass a valid help file id, silly!");
  183.         }
  184.         
  185.         $DB->query("DELETE FROM ibf_faq WHERE id='".$IN['id']."'");
  186.         
  187.         $std->boink_it($SKIN->base_url."&act=help");
  188.         exit();
  189.             
  190.         
  191.     }
  192.     
  193.     //=====================================================
  194.     
  195.     function doadd()
  196.     {
  197.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
  198.         
  199.         if ($IN['title'] == "")
  200.         {
  201.             $ADMIN->error("You must enter a title, silly!");
  202.         }
  203.         
  204.         
  205.         
  206.         $text  = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['text'] ) );
  207.         $title = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['title'] ) );
  208.         $desc  = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['description'] ) );
  209.         
  210.         $db_string = $DB->compile_db_insert_string( array( 'title'       => $title,
  211.                                                            'text'        => $text,
  212.                                                            'description' => $desc,
  213.                                                   )      );
  214.                                                   
  215.         $DB->query("INSERT INTO ibf_faq (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
  216.         
  217.         $std->boink_it($SKIN->base_url."&act=help");
  218.         exit();
  219.             
  220.         
  221.     }
  222.     
  223.     //=====================================================
  224.     
  225.     function list_files()
  226.     {
  227.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  228.     
  229.         $ADMIN->page_detail = "You may add/edit and remove help files below.";
  230.         $ADMIN->page_title  = "Help File Management";
  231.         
  232.         //+-------------------------------
  233.         
  234.         $SKIN->td_header[] = array( "Title"  , "50%" );
  235.         $SKIN->td_header[] = array( "Edit"   , "30%" );
  236.         $SKIN->td_header[] = array( "Remove" , "20%" );
  237.         
  238.         //+-------------------------------
  239.         
  240.         $ADMIN->html .= $SKIN->start_table( "Current Help Files" );
  241.         
  242.         $DB->query("SELECT * from ibf_faq ORDER BY id ASC");
  243.         
  244.         if ( $DB->get_num_rows() )
  245.         {
  246.             while ( $r = $DB->fetch_row() )
  247.             {
  248.                 
  249.                 $ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['title'])."</b><br>".stripslashes($r['description']),
  250.                                                           "<center><a href='".$SKIN->base_url."&act=help&code=edit&id={$r['id']}'>Edit</a></center>",
  251.                                                           "<center><a href='".$SKIN->base_url."&act=help&code=remove&id={$r['id']}'>Remove</a></center>",
  252.                                                  )      );
  253.                                                    
  254.             
  255.                 
  256.             }
  257.         }
  258.         
  259.         $ADMIN->html .= $SKIN->add_td_basic("<a href='".$SKIN->base_url."&act=help&code=new'>Add New Help File</a>", "center", "title" );
  260.         
  261.         $ADMIN->html .= $SKIN->end_table();
  262.         
  263.         //+-------------------------------
  264.         
  265.         $ADMIN->output();
  266.     
  267.     }
  268.     
  269.     
  270. }
  271.  
  272.  
  273. ?>